package top.whysu.study.thinkinjava.chapter9.interfaces.example3;

class A {
    private interface D {//---private
        void f();
    }
    private class DImp implements D { //was implemented by private class
        @Override
        public void f() {
            System.out.println("DImp f()");
        }
    }
    public class DImp2 implements D {//Notice:was implements by public class
        @Override
        public void f() {
            System.out.println("DImp2 f()");
        }
    }
    public D getD() { return new DImp2(); }
    private D dRef;
    public void receiveD(D d) {
        dRef = d;
        dRef.f();
    }
}